package com.rosense.nfvo.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Properties;

public class ZxConfig implements Serializable {
	
	private static final long serialVersionUID = 1L;
	// 获取token
	public String username;
	public String password;
	public String tokenUrl;
	public int tokenCode = 201;
	public String selectUrl;
	public int selectCode = 200;
	public String createUrl;
	public int createCode = 201;
	public String delUrl;
	public int delCode = 204;
	
	public String oss_username;
	public String oss_password;
	public String pushTokenUrl;
	public String pushCmUrl;
	public String pushPmUrl;
	public String pushFmUrl;
	
	
	private static ZxConfig instance = null;

	public ZxConfig() {
		Properties properties = new Properties();
		try {
//			InputStream in = this.getClass().getResourceAsStream("config.properties");
			InputStream in = new FileInputStream("/root/code/config/config-zx.properties");
			properties.load(in);
			this.username = properties.getProperty("username");
			this.password = properties.getProperty("password");
			this.tokenUrl = properties.getProperty("tokenUrl");
			this.tokenCode = Integer.parseInt(properties.getProperty("tokenCode"));
			this.selectUrl = properties.getProperty("selectUrl");
			this.selectCode = Integer.parseInt(properties.getProperty("selectCode"));
			this.createUrl = properties.getProperty("createUrl");
			this.createCode = Integer.parseInt(properties.getProperty("createCode"));
			this.delUrl = properties.getProperty("delUrl");
			this.delCode = Integer.parseInt(properties.getProperty("delCode"));
			this.oss_username = properties.getProperty("oss_username");
			this.oss_password = properties.getProperty("oss_password");
			this.pushTokenUrl = properties.getProperty("pushTokenUrl");
			this.pushCmUrl = properties.getProperty("pushCmUrl");
			this.pushPmUrl = properties.getProperty("pushPmUrl");
			this.pushFmUrl = properties.getProperty("pushFmUrl");
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static synchronized ZxConfig getInstance() {
		if (instance == null) {
			try {
				instance = new ZxConfig();
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return instance;
	}

	public static void main(String[] args) {
		System.out.println(ZxConfig.getInstance().createUrl);
	}
	
}
